package ads.server;

import java.util.HashMap;

public class SpreadMessageQueque {
	private static HashMap<String, SpreadResponseMessage> rcvMessage = new HashMap<String, SpreadResponseMessage>();

	public static void putMsg(SpreadResponseMessage msg) {
		synchronized (rcvMessage) {
			rcvMessage.put(msg.getId(), msg);
		}
//		println();
	}

	public static SpreadResponseMessage takeMsg(String id) {
		SpreadResponseMessage msg = null;
		synchronized (rcvMessage) {
			msg = rcvMessage.remove(id);
		}
//		println();
		return msg;
	}

	public static void println() {
		System.out.println("key of SpreadMessageQueque:");
		for (String id : rcvMessage.keySet()) {
			System.out.print(id + ",");
		}
		System.out.println();
	}
}
